package br.com.peri.conceito.resource;

import java.io.Serializable;

import org.jboss.resteasy.client.ProxyFactory;
import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
import org.jboss.resteasy.spi.ResteasyProviderFactory;
import org.jboss.seam.annotations.Factory;
import org.jboss.seam.annotations.Name;

import br.com.peri.rs.PessoaResource;
import br.com.peri.rs.UsuarioResource;
import br.com.peri.ws.client.PessoaWebService;
import br.com.peri.ws.client.PessoaWebService_Service;

@Name("periResource")
public class PeriResource implements Serializable {

	private static final long serialVersionUID = 1L;
	private static final String URL_BASE_PERI_EXEMPLO = "http://localhost:8080/peri-ws/rest";

	@Factory
	public PessoaResource getPessoaResource() {
		ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
		RegisterBuiltin.register(factory);
		return ProxyFactory.create(PessoaResource.class,
				URL_BASE_PERI_EXEMPLO);
	}

	@Factory
	public UsuarioResource getUsuarioResource() {
		ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
		RegisterBuiltin.register(factory);
		return ProxyFactory.create(UsuarioResource.class,
				URL_BASE_PERI_EXEMPLO);
	}

	@Factory
	public PessoaWebService getPessoaWebService() {
		return new PessoaWebService_Service().getPessoaWebServicePort();
	}

}
